﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Model;
using BLL;

namespace ClassSystem
{
    public partial class ASPUpdateRizhi : System.Web.UI.Page
    {
        GonggaoBLL bll = new GonggaoBLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Label1.Text = DateTime.Now.ToString();
                this.Repeater1.DataSource = bll.GetListAll();
                this.Repeater1.DataBind();
          
            if (!string.IsNullOrEmpty(Request["ID"]))
            {
                int ID = Convert.ToInt32(Request["ID"]);
                Gonggao PM = bll.GetListAll().Where(a => a.GonggaoID == ID).FirstOrDefault();
                if (PM.NowState == 0)
                {
                    PM.NowState = 1;
                }

                if (bll.Update(PM))
                {
                    Response.Redirect("ASPAdminUpdateRizhi.aspx");
                }
                else
                {
                    Response.Write("<script>alert('修改失败！')</script>");
                }

            }

        }
        public static string FontType(string val)
        {
            if (val == "0")
            {
                return "未读";
            }
            else
            {
                return "已读";
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string StudentNames = this.txtox.Text.Trim();
            var result= bll.GetListAll1(StudentNames);
            if (result != null)
            {
                this.Repeater1.DataSource = bll.GetListAll1(StudentNames);
                this.Repeater1.DataBind();
            }
            else
            {
                Response.Write("<script>alert('查询失败！')</script>");
            }



        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            int NowState = Convert.ToInt32(this.DropDownList1.SelectedValue);
            List<Gonggao> list = bll.GetListAll().Where(a => a.NowState == NowState).ToList();
            if (list != null)
            {
                this.Repeater1.DataSource = list;
                this.Repeater1.DataBind();
            }
            if (list.Count == 0)
            {
                Response.Write("<script>alert('查询失败！')</script>");
            }
        }
    }
}